package com.sdgakj.study.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Author: Du Ronghong
 * @Description:
 * @Date: Created in 17:34 2018/8/28
 * @Modified By:
 */
public class ThreadImplementsCallbale implements Callable<String> {

    private String str = "";


    public static void main(String[] args) {
        try {
            FutureTask<String> futureTask = new FutureTask<>(new ThreadImplementsCallbale());
            futureTask.run();
            String s = futureTask.get();
            System.out.println(s);
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }

    }

    @Override
    public String call() throws Exception {
        for (int i = 0; i < 10; i++) {
            str = String.format("%s%d", str, i);
        }
        return str;
    }
}
